package org.deltaset.samples.petclinic.domain;

import java.io.Serializable;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.constraints.Min;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Version;

import javax.persistence.Enumerated;
import org.deltaset.samples.petclinic.reference.PetType;

@Entity
public class Pet implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;
    @Version
    @Column(name = "version")
    private Integer version;
    @NotNull
    private boolean sendReminders;
    @NotNull
    @Size(min = 1)
    private String name;
    @NotNull
    @Min(0L)
    private Float weight;
    @ManyToOne
    private Owner owner;
    @NotNull
    @Enumerated
    private PetType type;

    public boolean isSendReminders() {
        return this.sendReminders;
    }

    public void setSendReminders(boolean sendReminders) {
        this.sendReminders = sendReminders;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Float getWeight() {
        return this.weight;
    }

    public void setWeight(Float weight) {
        this.weight = weight;
    }

    public Owner getOwner() {
        return this.owner;
    }

    public void setOwner(Owner owner) {
        this.owner = owner;
    }

    public PetType getType() {
        return this.type;
    }

    public void setType(PetType type) {
        this.type = type;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getVersion() {
        return this.version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("Name: ").append(getName()).append(", ");
        sb.append("Owner: ").append(getOwner()).append(", ");
        sb.append("Type: ").append(getType()).append(", ");
        sb.append("Version: ").append(getVersion()).append(", ");
        sb.append("Weight: ").append(getWeight()).append(", ");
        sb.append("SendReminders: ").append(isSendReminders());
        return sb.toString();
    }
}
